﻿const connection = new signalR.HubConnectionBuilder().withUrl("/chatHubs").build();
connection.start().then(function () {
    console.log("连接成功!");
}).catch(function (err) {
    console.log("连接失败!" + err.toString());
});

async function start() {
    try {
        await connection.start();
        console.log("connected");
    } catch (err) {
        console.log(err);
        setTimeout(() => start(), 10000);
    }
};

connection.onclose(async () => {
    start();
});